from tortoise.models import Model
from tortoise import fields

class DailySignIn(Model):
    id = fields.IntField(pk=True)
    user = fields.ForeignKeyField("models.User", related_name="sign_ins")  # 关联用户
    sign_date = fields.DateField()  # 签到日期
    points_earned = fields.IntField()  # 本次签到获得的积分（含额外奖励）
    continuous_days = fields.IntField()  # 连续签到天数
    created_at = fields.DatetimeField(auto_now_add=True)  # 记录创建时间

    class Meta:
        table = "daily_sign_ins"
        unique_together = (("user", "sign_date"),)  # 确保用户单日只能签到一次